var e = require, t = module, n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
});

var o = e("GameConfig"), i = e("GameData"), a = e("enum"), r = function() {
    function u() {}
    return u.getInstance = function() {
        return this._manager || (this._manager = new u()), this._manager;
    }, u.prototype.isHas = function(t) {
        return this.getData(t).has;
    }, u.prototype.isEquip = function(t, e) {
        return 1 == e ? t == i.GD.backEquipIdx : 2 == e && t == i.GD.headEquipIdx;
    }, u.prototype.doEquip = function(t, e) {
        1 == e ? i.GD.backEquipIdx = t : 2 == e && (i.GD.headEquipIdx = t);
    }, u.prototype.addEquip = function(t) {
        var e = this.getData(t);
        e.has ? e.lv < 30 && (e.lv++, e.form = Math.min(2, Math.floor(e.lv / 10)), this.setData(t, e)) : (e.has = 1, 
        this.setData(t, e));
    }, u.prototype.setData = function(t, e) {
        for (var a = !1, n = 0; n < i.GD.equipDataList.length; n++) i.GD.equipDataList[n].id == t && (a = !0, 
        i.GD.equipDataList[n] = e);
        a || i.GD.equipDataList.push(e);
    }, u.prototype.getConfig = function(e) {
        var t = o.GC.equipConfigList.filter(function(t) {
            return t.id == e;
        });
        return (0 < t.length ? t : o.GC.equipConfigList)[0];
    }, u.prototype.getData = function(e, t) {
        t = (t = void 0 === t ? i.GD.equipDataList : t).filter(function(t) {
            return t.id == e;
        });
        return 0 < t.length ? t[0] : {
            id: e,
            lv: 0,
            form: 0,
            has: 0
        };
    }, u.prototype.getProps = function(t, e) {
        return t < e.start ? {
            type: e.type,
            value: 0
        } : {
            type: e.type,
            value: e.value + e.up * (t - e.start)
        };
    }, u.prototype.getCost = function(t) {
        return 0 < t ? 100 * t : 100;
    }, u.prototype.getProp = function(t, e, n, r) {
        void 0 === r && (r = i.GD.equipDataList);
        var o = u.getInstance().getConfig(t), p = u.getInstance().getData(t, r);
        return o.props.forEach(function(t) {
            if (t.type == n) switch (n) {
              case a.EquipPropType.ATK_P:
              case a.EquipPropType.MOVE_P:
                e += Math.round(e * u.getInstance().getProps(p.lv, t).value / 100);
                break;

              case a.EquipPropType.CRI_P:
                e += u.getInstance().getProps(p.lv, t).value;
                break;

              case a.EquipPropType.SPE_P:
                e += e * u.getInstance().getProps(p.lv, t).value / 100;
                break;

              case a.EquipPropType.RAN_P:
                e += Math.round(e * u.getInstance().getProps(p.lv, t).value / 100);
                break;

              case a.EquipPropType.MISS_P:
              case a.EquipPropType.HP_V:
                e += u.getInstance().getProps(p.lv, t).value;
            }
        }), e;
    }, u.prototype.getRandHeadEquipIdx = function() {
        var e = [];
        return o.GC.equipConfigList.forEach(function(t) {
            2 == t.type && e.push(t.id);
        }), e[GA.rand(0, e.length - 1)];
    }, u.prototype.getRandBackEquipIdx = function() {
        var e = [];
        return o.GC.equipConfigList.forEach(function(t) {
            1 == t.type && e.push(t.id);
        }), e[GA.rand(0, e.length - 1)];
    }, u._manager = null, u;
}();

n.default = r;